package main

import (
	"log"
	"os"
	"time"
	influxdb "github.com/vrischmann/go-metrics-influxdb"
	"github.com/rcrowley/go-metrics"
)
func main()  {
	//

	infludb()
}

func infludb()  {
	m := metrics.NewMeter()
	metrics.Register("test", m)
	m.Mark(1)

	go influxdb.InfluxDB(metrics.DefaultRegistry, time.Second * 5, "http://10.17.10.40:8086", "gao_test", "test", "","",true)

	for true {
		time.Sleep(time.Second*2)
		m.Mark(1)
	}



	//go influxdb.InfluxDBWithTags(
	//	metrics.DefaultRegistry,    // metrics registry
	//	time.Second * 10,           // interval
	//	"http://10.17.10.40:8086",                // the InfluxDB url
	//	"gtest",                   // your InfluxDB database
	//	"test",                // your measurement
	//	"gaojiyong",                // your InfluxDB user
	//	"gaojiyong",                // your InfluxDB password
	//	nil,                       // your tag set as map[string]string
	//	true,             // align the timestamps
	//)
}
func gauge()  {
	g := metrics.NewGauge()
	metrics.Register("bar", g)
	g.Update(1)


	go metrics.Log(metrics.DefaultRegistry,
		2 * time.Second,
		log.New(os.Stdout, "metrics: ", log.Lmicroseconds))


	var j int64
	j = 1
	for true {
		time.Sleep(time.Second * 1)
		g.Update(j)
		j++
	}



	c := metrics.NewCounter()
	metrics.Register("foo", c)
	c.Inc(45)

	c.Dec(3)
}

func meter()  {
	m := metrics.NewMeter()
	metrics.Register("quux", m)
	m.Mark(1)


	go metrics.Log(metrics.DefaultRegistry,
		2 * time.Second,
		log.New(os.Stdout, "metrics: ", log.Lmicroseconds))


	//var j int64
	//j = 1
	for true {
		time.Sleep(time.Second * 10)
		//j++
		//fmt.Println(j)
		m.Mark(1)
	}
}
